/*  
 *  Copyright 2006 Paul Jack.
 *
 *  This file is part of the Dex compiler suite. 
 *  
 *  Dex is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU General Public License as published by the
 *  Free Software Foundation; either version 2 of the License, or (at your
 *  option) any later version.
 *  
 *  Dex is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 *  Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 */
package dex.compiler.checker;


import dex.compiler.model.definition.Unit;
import dex.compiler.model.program.Program;
import dex.compiler.problem.Reporter;


/**
 * Configuration object for checkers.
 */
public class CheckerConfig {


	/**
	 * The program being checked.
	 */
	private Program program;
	
	
	/**
	 * The unit being checked.
	 */
	private Unit unit;

	
	/**
	 * The reporter used to display errors or warnings.
	 */
	private Reporter reporter;
	

	/**
	 * Constructs a new CheckerConfig with null properties.
	 */
	public CheckerConfig() {
	}


	/**
	 * Returns the program to be checked.
	 * 
	 * @return  the program to be checked
	 */
	public Program getProgram() {
		return program;
	}


	/**
	 * Sets the program to be checked.
	 * 
	 * @param program  the program to be checked
	 */
	public void setProgram(Program program) {
		this.program = program;
	}


	/**
	 * Returns the reporter used to report errors and warnings.
	 * 
	 * @return  the reporter to be used
	 */
	public Reporter getReporter() {
		return reporter;
	}


	/**
	 * Sets the reporter used to report errors and warnings.
	 * 
	 * @param reporter  the reporter to be used
	 */
	public void setReporter(Reporter reporter) {
		this.reporter = reporter;
	}


	/**
	 * Returns the unit to be checked.
	 * 
	 * @return  the unit to be checked
	 */
	public Unit getUnit() {
		return unit;
	}


	/**
	 * Sets the unit to be checked.
	 * 
	 * @param unit  the unit to be checked
	 */
	public void setUnit(Unit unit) {
		this.unit = unit;
	}


	/**
	 * Validates that the configuration is valid.
	 * 
	 * @throws IllegalArgumentException  if the configuration isn't valid
	 */
	public void validate() {
		if (unit == null) {
			throw new IllegalArgumentException("unit may not be null");
		}
		if (reporter == null) {
			throw new IllegalArgumentException("reporter may not be null");
		}
		if (program == null) {
			throw new IllegalArgumentException("program may not be null");
		}
	}

}
